import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * Date: 2025-11-06
 * Time: 12:48
 */
public class Test {

    //使用ArrayList实现杨辉三角“
    public static List<List<Integer>> YHui(int row) {

        List<List<Integer>> list = new ArrayList<>();
        if (row == 0) {
            return null;
        }
        List<Integer> arrayList = new ArrayList<>();
        arrayList.add(1);
        list.add(arrayList);

        if (row == 1) {
            return list;
        }

            List<Integer> arryList2 = new ArrayList<>();
        arryList2.add(1);
        arryList2.add(1);
        list.add(arryList2);
        if (row == 2){
            return list;
        }
        //System.out.println(list);

        for (int i = 2; i < row; i++) {
            List<Integer> list1 = new ArrayList<>();
            //开头
            list1.add(1);
            List<Integer>  cList = list.get(i-1);

            //中间
            for (int j = 1; j < i; j++) {
                Integer a1 = cList.get(j);
                Integer a2 = cList.get(j-1);
                Integer a = a1 + a2;
                list1.add(a);
            }

            //结尾：
            list1.add(1);
            list.add(list1);
        }
        return list;

    }

    public static void main1(String[] args) {
        List<List<Integer>> list = YHui(3);
        System.out.println(list);
    }

    //简单的洗牌算法
    public static void main(String[] args) {
        //买一副牌
        CardDemo cardDemo = new CardDemo();
        List<Card> cards = cardDemo.buyCard();
        System.out.println(cards);
        System.out.println("================");
        //洗牌
        List<Card> cards1 = cardDemo.shuffle(cards);
        System.out.println(cards1);

        //三个人，每个人每轮拿一张牌，拿五轮

        List<List<Card>> change = new ArrayList<>();
//        List<Card> hand1 = new ArrayList<>();
//        List<Card> hand2 = new ArrayList<>();
//        List<Card> hand3 = new ArrayList<>();
        change.add(new ArrayList<>());
        change.add(new ArrayList<>());
        change.add(new ArrayList<>());

        for (int i = 0; i < 5; i++) {
            List<Card> hand = new ArrayList<>();
            for (int j = 0; j < 3; j++) {
                //获取不同对象
                hand = change.get(j);
                hand.add(cards1.remove(0)) ;
            }
        }
        System.out.println(cards1);
        System.out.println(change);
    }

}
